package models;
 
import java.math.BigDecimal;
import java.util.*;
import javax.persistence.*;
 
import play.data.validation.Required;
import play.db.jpa.*;
 
@Entity
public class Position extends Model {
 

	@ManyToOne
	public Customer customer;
	
	@Required
	@ManyToOne
	public Fund fund;


	public BigDecimal shares;
	
	public Position(Customer customer, Fund fund, BigDecimal shares) {
		this.customer = customer;
		this.fund = fund;
		this.shares = shares;
	}
	
	public Position(Fund fund) {
		this.customer = null;
		this.fund = fund;
		this.shares = null;
	}
	
	public String toString() {
		if(customer==null){
			return "pending" + " - " +fund.toString();
		}
		else{
			return customer.toString() + " - " + fund.toString();
		}
	}
	
}